import { defineConfig } from 'vite'
import { resolve } from 'path'
import react from '@vitejs/plugin-react'

function pathResolve(dir: string) {
  return resolve(process.cwd(), '.', dir)
}

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: [
      {
        find: /\@\//,
        replacement: `${pathResolve('src')}/`
      }
    ]
  },
  server: {
    host: true,
    port: 3001,
    proxy: {
      '/dev-api': {
        target: 'http://118.89.76.83:13000',
        changeOrigin: true,
        rewrite: path => path.replace(new RegExp(`^/dev-api`), '')
      }
    }
  }
})
